<link rel="stylesheet" href="/static/markdown/css/editormd.preview.css"/>
<style type="text/css">
    table
    {
        border-collapse: collapse;
        margin: 0 auto;
        text-align: center;
    }
    table td, table th
    {
        border: 1px solid #cad9ea;
        color: #666;
        height: 20px;
    }
    table thead th
    {

        width: 100px;
    }
    table tr:nth-child(odd)
    {

    }
    table tr:nth-child(even)
    {

    }
</style>
<div class="layui-form" id="layuiadmin-form-admin" lay-filter="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-row">
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4" style="display: none;">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    日志类别
                </label>
                <div class="layui-input-block">
                    <select id="journal_type_id" lay-verify="required" lay-filter="journal_type_id" lay-search=""
                            disabled>
                        <option value="">请选择日志类别</option>
                        {foreach $journal_type as $key=>$vo}
                        <option value="{$vo.id}" {if condition="($model.journal_type_id eq $vo.id)" }selected{/if}>{$vo.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
        </div>
<!--        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">-->
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">-->
<!--                    人员名称-->
<!--                </label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input autocomplete="off" class="layui-input" id="period" value="{$model.admin_name ?? ''}"-->
<!--                           placeholder="请输入人员名称" required="" type="text" readonly/>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    所属部门
                </label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" value="{$model.group_name ?? ''}"
                           placeholder="请输入所属部门" required="" type="text" readonly /ss>
                </div>
            </div>
        </div>
		<div id="xinzeng"></div>
        {if $model['journal_level_id'] neq ''}
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label" style="color: red;">
                    日志等级
                </label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" value="{$model.JournaLevel.name ?? ''}"
                           placeholder="日志等级" required="" type="text" readonly/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label" style="color: red;">
                    审批人
                </label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" value="{$model.Admin.nickname ?? ''}"
                           placeholder="审批人" required="" type="text" readonly/>
                </div>
            </div>
        </div>
        {/if}
        {if $model['remarks'] neq ''}
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label" style="color: red;">
                    批注
                </label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" value="{$model.remarks ?? ''}" placeholder="批注"
                           required="" type="text" readonly>
                    </input>
                </div>
            </div>
        </div>
        {/if}
        <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    内容填写
                </label>
                <div class="layui-input-block">
                    {empty name="$model.week"}
                    <div id="test-editormd-view2">
                        <textarea id="append-test" style="display:none;">{$model.markdown_content}</textarea>
                    </div>
                    {else /}
                    <table style="width: 100%">
                        <thead>

                        <tr>
                            <th style="text-align: center;">
                                日期
                            </th>
                            <th style="text-align: center;">
                                今日工作
                            </th>
                            <th style="text-align: center;">
                                工作进度
                            </th>
                        </tr>
                        </thead>
                        {foreach $model.week as $key=>$vo }

                        <tr>
                            <td style="text-align: center;">
                                <input type="hidden" name="week_id[]" value="{$vo.id ?? ''}">
                                <input type="hidden" name="xingqi[]" value="{$vo.xingqi}">{$vo.xingqi ?? ''}
                            </td>
                            <td style="text-align: center;">
                                {$vo.content ?? ''}
                            </td>
                            <td style="text-align: center;">
                                {$vo.jindu ?? ''}
                            </td>
                        </tr>

                        {/foreach}
                    </table>
                    {/empty}
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="LAY-user-back-submit" id="LAY-user-back-submit" value="确认">
        </div>
    </div>
</div>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/markdown/js/jquery.min.js"></script>
<script src="/static/markdown/lib/marked.min.js"></script>
<script src="/static/markdown/lib/prettify.min.js"></script>
<script src="/static/markdown/lib/raphael.min.js"></script>
<script src="/static/markdown/lib/underscore.min.js"></script>
<script src="/static/markdown/lib/sequence-diagram.min.js"></script>
<script src="/static/markdown/lib/flowchart.min.js"></script>
<script src="/static/markdown/lib/jquery.flowchart.min.js"></script>
<script src="/assets/libs/editormd/editormd.min.js"></script>
<script>
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
        treeTable: '../admin/lib/extend/authtree'
    }).use(['index', 'table', 'form'], function () {
        var $ = layui.$, form = layui.form, table = layui.table;
        table.init('demo', {
            height: 315, //设置高度
            size:"sm"
        });
        var id = $("#journal_type_id option:selected").val();
        select_type(id);

        form.on('select(journal_type_id)', function (data) {
            select_type(data.value);
        });

        function select_type(id) {
            var html = "";
            var str = "";
            $.ajax({
                url: "{:url('journal/select_type')}",
                type: "post",
                data: {'id': id},
                dataType: "json",
                success: function (res) {
                    var data = eval('(' + res + ')');
                    $("#xinzeng").empty();
                    html += "<div class=\"layui-col-xs12 layui-col-sm6 layui-col-md4\">";
                    html += "<div class=\"layui-form-item\">";
                    html += "<label class=\"layui-form-label\">第x" + $("#journal_type_id option:selected").text() + "</label>";
                    html += "<div class=\"layui-input-block\">";
                    html += "<select  id=\"is_week\" lay-verify=\"required\" lay-filter=\"is_week\" disabled>";
                    html += "<option value=\"\">请选择日志类别</option>";
                    str += "<div class=\"layui-col-xs12 layui-col-sm6 layui-col-md4\">";
                    str += "<div class=\"layui-form-item\">";
                    str += "<label class=\"layui-form-label\">所属范围</label>";
                    str += "<div class=\"layui-input-block\">";
                    $.each(data, function (index, el) {
                        if (el.detail == "{$model.is_week}") {
                            html += "<option value=\"" + el.detail + "\" data-name=\"" + el.fanwei + "\" selected>" + el.detail + "</option>";
                            str += "<input class=\"layui-input\" id=\"week_time\" placeholder=\"请输入所属范围\" value=\"{$model.week_time ?? ''}\" required=\"\" type=\"text\" readonly /> ";
                        } else {
                            html += "<option value=\"" + el.detail + "\"  data-name=\"" + el.fanwei + "\">" + el.detail + "</option>";
                        }
                    });
                    html += " </select>";
                    html += "</div></div></div>";
                    str += "</div></div></div>";
                    $("#xinzeng").append(html);
                    $("#xinzeng").append(str);
                    form.render('select');
                }
            });
        }

        form.on('select(is_week)', function (event) {
            var fanwei = $('#is_week').find("option:selected").data("name");
            $('#week_time').val(fanwei);
        });
    });
</script>
<script type="text/javascript">
    $(function () {
        var testEditormdView2;
        testEditormdView2 = editormd.markdownToHTML("test-editormd-view2", {
            htmlDecode: "style,script,iframe",  // you can filter tags decode
            emoji: true,
            taskList: true,
            tex: true,  // 默认不解析
            flowChart: true,  // 默认不解析
            sequenceDiagram: true,  // 默认不解析
        });
    });
</script>